/**
 * 로그관련모듈
 * 
 * @author KJH
 * @version 1.0, 2012-02-28 
 * @fix([수정자]) [yyyy-mm-dd]: [수정 내용]
 *
*/

package com.ubst.smartad.logger;

import com.ubst.smartad.common.TimeUtil;

public class Debug{
	public int loglevel = 0;
	public String className = "WEBDRIVE";

	public Debug(String ClassName, String log_lev){
		if(ClassName!=null && !ClassName.equals("")){
			className = ClassName;
		}

		if(log_lev != null){
			if(log_lev.equals("FATAL")){
				this.loglevel = 1;
			}else if(log_lev.equals("ERROR")){
				this.loglevel = 5;
			}else if(log_lev.equals("WARN")){
				this.loglevel = 10;
			}else if(log_lev.equals("INFO")){
				this.loglevel = 15;
			}else if(log_lev.equals("DEBUG")){
				this.loglevel = 20;
			}else{
				this.loglevel = 0;
			}
		}
	}

	public void fatal(String message){
		if(loglevel==1 || loglevel==5 || loglevel==10 || loglevel==15 || loglevel==20){
			String currentTime = TimeUtil.getDateString(TimeUtil.getCurrentTime(), "yyyy-MM-dd HH:mm:ss");
			System.out.println(currentTime +" FATAL ["+className +"] "+message);
			//logger.fatal(message);
		}
	}

	public void error(String message){
		if(loglevel==5 || loglevel==10 || loglevel==15 || loglevel==20){
			String currentTime = TimeUtil.getDateString(TimeUtil.getCurrentTime(), "yyyy-MM-dd HH:mm:ss");
			System.out.println(currentTime +" ERROR ["+className +"] "+message);
			//logger.error(message);
		}
	}

	public void warn(String message){
		if(loglevel==10 || loglevel==15 || loglevel==20){
			String currentTime = TimeUtil.getDateString(TimeUtil.getCurrentTime(), "yyyy-MM-dd HH:mm:ss");
			System.out.println(currentTime +" WARN ["+className +"] "+message);
			//logger.warn(message);
		}
	}

	public void info(String message){
		if(loglevel==15 || loglevel==20){
			String currentTime = TimeUtil.getDateString(TimeUtil.getCurrentTime(), "yyyy-MM-dd HH:mm:ss");
			System.out.println(currentTime +" INFO ["+className +"] "+message);
			//logger.info(message);
		}
	}

	public void debug(String message){
		if(loglevel==20){
			String currentTime = TimeUtil.getDateString(TimeUtil.getCurrentTime(), "yyyy-MM-dd HH:mm:ss");
			System.out.println(currentTime +" DEBUG ["+className +"] "+message);
			//logger.debug(message);
		}
	}
	
	/*
	public void debug(String message){
		if(loglevel==0){	// 로그출력 안함
		}else if(loglevel<=1){
			String currentTime = TimeUtil.getDateString(TimeUtil.getCurrentTime(), "yyyy-MM-dd HH:mm:ss");
			System.out.println(currentTime +" FATAL ["+className +"] "+message);
			//logger.fatal(message);
		}else if(loglevel<=5){
			String currentTime = TimeUtil.getDateString(TimeUtil.getCurrentTime(), "yyyy-MM-dd HH:mm:ss");
			System.out.println(currentTime +" ERROR ["+className +"] "+message);
			//logger.error(message);
		}else if(loglevel<=10){
			String currentTime = TimeUtil.getDateString(TimeUtil.getCurrentTime(), "yyyy-MM-dd HH:mm:ss");
			System.out.println(currentTime +" WARN ["+className +"] "+message);
			//logger.warn(message);
		}else if(loglevel<=15){
			String currentTime = TimeUtil.getDateString(TimeUtil.getCurrentTime(), "yyyy-MM-dd HH:mm:ss");
			System.out.println(currentTime +" INFO ["+className +"] "+message);
			//logger.info(message);
		}else if(loglevel<=20){
			String currentTime = TimeUtil.getDateString(TimeUtil.getCurrentTime(), "yyyy-MM-dd HH:mm:ss");
			System.out.println(currentTime +" DEBUG ["+className +"] "+message);
			//logger.debug(message);
		}
	}
	*/

}
